<html>
<head>
    <meta charset="utf-8">
    <#assign base=request.contextPath  />
    <#setting  number_format="0.##"/>
    <title>商家审核</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1.0, minimum-scale=1.0, maximum-scale=1.0, user-scalable=0">
    <link rel="stylesheet" href="${base}/backstage/layui/css/layui.css" media="all">
    <script src="${base}/backstage/js/jquery-1.8.3.min.js"></script>
    <script src="${base}/backstage/layui/layui.js"></script>
    <script src="${base}/backstage/js/feng.js"></script>
    <script src="${base}/backstage/js/ipNameUrl.js"></script>
    <script>
        var base =  "${base}";
    </script>
    <style>
        /*给数据表格加高*/
        .layui-table-cell{
            height:50%;
        }

    </style>
</head>
<body>
<br>
<div class="demoTable" style="margin-left: 15px;">
    <form class="layui-form " action="">
        <div class="layui-form-item">
            <div class="layui-inline">
                <label>账户</label>
                <div class="layui-inline">
                    <input class="layui-input" name="account" id="account" placeholder="请输入账户" autocomplete="off">
                </div>
            </div>
            <div class="layui-inline">
                <label>身份证号</label>
                <div class="layui-inline">
                    <input class="layui-input" name="idNumber" id="idNumber" placeholder="请输入身份证号" autocomplete="off">
                </div>
            </div>

            <button class="layui-btn" onclick="sech()" data-method="offset"
                    type="button">查询
            </button>
        </div>
    </form>
</div>
<table class="layui-hide" id="test" lay-filter="test"></table>
<script type="text/html" id="barDemo">

    <button class="layui-btn" lay-event="edit" onclick="success('{{d.id}}')" >通过</button>&nbsp;
    <button class="layui-btn" lay-event="del" onclick="error('{{d.id}}')"
            style="background: red;color: #FFFFFF">失败
    </button>
</script>
<script type="text/html" id="toolbarDemo">
    <form class="layui-form " action="">
        <div class="layui-form-item" style="margin-left: 15px;">
            <div class="layui-btn-group">
                <button class="layui-btn" id="btn2" data-method="offset" type="button">添加</button>
            </div>
        </div>
    </form>
</script>
<script>
    layui.use(['table', 'form', 'layedit', 'laydate'], function () {
        var form = layui.form
            , $ = layui.jquery
            , layer = layui.layer
            , layedit = layui.layedit
            , laydate = layui.laydate
            , table = layui.table;

        var whereData = {}
        whereData.account = $("#account").val();
        whereData.idNumber = $("#idNumber").val();

        table.render({
            skin: 'line' //行边框风格
            , even: true //开启隔行背景
            , elem: '#test'
            ,where:whereData
            , url: '${base}/admin/userInfo/selectMyPage1'
            , toolbar: '#toolbarDemo'
            ,cols:[[
                {field:'id', title: '序号',templet:function(val){
                        return val.LAY_INDEX
                    },align:'center'},
                {field:'account', title: '账户', align:'center'},
                {field:'passWord', title: '密码',  align:'center'},
                {field:'phone', title: '手机号', align:'center'},
                {field:'address', title: '地址', align:'center'},
                {field:'idNumber', title: '身份证号', align:'center'},
                {field:'nickName', title: '昵称', align:'center'},
                {field:'userUrl', title: '头像',templet:function(val){
                        return "<img src="+val.userUrl+">";
                    },   align:'center'},
                {field:'url', title: '营业执照',templet:function(val){
                        return "<img src="+val.url+">";
                    },  align:'center'},
                {field:'positive', title: '身份证正面', templet:function(val){
                        return "<img src="+val.positive+">";
                    }, align:'center'},
                {field:'side', title: '身份证反面',templet:function(val){
                        return "<img src="+val.side+">";
                    },  align:'center'},
                {field:'createTime', title: '创建时间',templet:function(val){
                        if(val.createTime==undefined){
                            return "";
                        }
                        return changeDateFormat(val.createTime);
                    },  align:'center'},
                {field: 'right', title: '操作', width:200,toolbar: '#barDemo', align: 'center'}
            ]]
            , id: 'testReload'
            , page: {
                layout: ['limit', 'count', 'prev', 'page', 'next', 'skip'] //自定义分页布局
                , theme: '#1AB394'
                , limit: 10
            }
        });




    })
    //通过
    function success(id) {
        layer.confirm('真的要通过该商家吗?', function (index) {
            $.ajax({
                type: "POST",
                url: "${base}/admin/userInfo/success",
                data: {id: id},
                sync: false,
                success: function (data) {
                    if (data.code === 200) {
                        layer.msg(data.msg)
                        setTimeout(function () {
                            window.location.reload();
                        }, 500)
                    } else {
                        layer.msg(data.msg)
                    }

                }
            });
        });
    }
    //失败
    function error(id) {
                layer.open({
                    type: 2  //type等于2跳转页面
                    ,content: '${base}/admin/userInfo/error.html?id='+id
                    ,title: '失败原因'
                    ,closeBtn:2 //不显示关闭的X
                    ,anim: 1
                    ,shadeClose:false
                    ,area:['550px','300px']//宽高
                    ,btnAlign: 'c' //按钮居中
                    ,shade: 0.8 //不显示遮罩
                });
        <#--layer.confirm('真的要失败该商家吗?', function (index) {-->
        <#--    $.ajax({-->
        <#--        type: "POST",-->
        <#--        url: "${base}/admin/userInfo/error",-->
        <#--        data: {id: id},-->
        <#--        sync: false,-->
        <#--        success: function (data) {-->
        <#--            if (data.code === 200) {-->
        <#--                layer.msg(data.msg)-->
        <#--                setTimeout(function () {-->
        <#--                    window.location.reload();-->
        <#--                }, 500)-->
        <#--            } else {-->
        <#--                layer.msg(data.msg)-->
        <#--            }-->

        <#--        }-->
        <#--    });-->
        <#--});-->
    }
    //搜索
    function sech() {
        var whereData = {}
        whereData.account = $("#account").val();
        whereData.idNumber = $("#idNumber").val();
        //表刷新方法
        var table = layui.table;
        table.reload('testReload', {
            url: '${base}/admin/userInfo/selectMyPage1'
            , where: whereData
        });
        $("#account").val("");
        $("#idNumber").val("");
    }
</script>

</body>

</html>


